

<template tag="以下文档内容为hycli自动生成">
  <el-dialog
    v-model="conf.visible"
    
    :title="title"
    :width="conf.width"
    draggable
    align-center="true"
    :close-on-click-modal="false"
  >
<el-form :model="form"  ref="form" :rules="rules_aaate">
    <el-row>
    <el-col :span="12">
    <!-- {"index":76,"raw":"sys_id","name":"sys_id","cname":"SysId","type":{"raw":"number(10)","name":"number","len":10,"dlen":0},"defValue":"0","allowNull":true,"constraints":["UNQ(unq_sso_userrole_usr,3)","l","le","v","sl(system_info)","c","u"],"desc":{"raw":"系统","name":"系统"}} -->
     <!--系统 下拉控件 -->
    <el-form-item prop="sys_id" label="系统" label-width="100px" label-position="right">
      <el-select   v-model="form.sys_id" style="width: 100%" filterable clearable
        placeholder="请选择系统" >
        <el-option v-for="item in sys_idList" :key="item.value" :label="item.name" :value="item.value" />
      </el-select>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":77,"raw":"role_id","name":"role_id","cname":"RoleId","type":{"raw":"number(10)","name":"number","len":10,"dlen":0},"defValue":"","allowNull":false,"constraints":["UNQ(unq_sso_userrole_usr,4)","l","le","v","c","u","sl(role_info)","tp(tag,l)"],"desc":{"raw":"角色","name":"角色"}} -->
     <!--角色 下拉控件 -->
    <el-form-item prop="role_id" label="角色" label-width="100px" label-position="right">
      <el-select   v-model="form.role_id" style="width: 100%" filterable clearable
        placeholder="请选择角色" >
        <el-option v-for="item in role_idList" :key="item.value" :label="item.name" :value="item.value" />
      </el-select>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":78,"raw":"status","name":"status","cname":"Status","type":{"raw":"tinyint(1)","name":"tinyint","len":1,"dlen":0},"defValue":"1","allowNull":false,"constraints":["l","le","v","c","u","sl","tp(radio,c-u)","tp(tag,l)"],"desc":{"raw":"状态 0启用 1禁用","name":"状态"}} -->
    <el-form-item prop="status" label="状态" label-width="100px" label-position="right">
      <el-radio-group v-model="form.status"   >
        <el-radio-button v-for="item in statusList" :key="item.value" :label="item.value" >
            {{item.name}}
        </el-radio-button>
      </el-radio-group>
      <el-tooltip raw-content="true" content="状态 0启用 1禁用" placement="bottom" effect="light">
      <i class="form_item_info fa fa-info-circle"  aria-hidden="true" />
      </el-tooltip>
    </el-form-item>
    </el-col>
    </el-row>
</el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="hide" icon="close">取消</el-button>
        <el-button type="primary" @click="save" icon="select">提交</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script>
import rtext from "@/views/cmpnts/rtext.vue"
export default {
  components: {
    rtext
},
  data() {
    return {
      conf: {
        visible: false,
        width:"60%",
        uploadPath:this.$theia.env.join("/file/upload"),
      },
      title:"修改用户权限",
rules_aaate:{
    sys_id:[{required:false,message:"请输入系统",trigger: 'blur'}],
    role_id:[{required:true,message:"请输入角色",trigger: 'blur'}],
    status:[{required:true,message:"请输入状态",trigger: 'blur'}],
  },
    form:{
        sys_id:"",
        role_id:"",
        status:"",
    },
    sys_idList:[],
    role_idList:[],
    statusList:[],
    }
  },
  methods: {
    show(form) {
      this.conf.visible = true;
      this.loadEnums_aaate()
      this.form = Object.assign(form,this.$route.params)
      this.get(form)
    },
      get(form){
        let that = this
        this.conf.loading = true
        let postForm = {}
        postForm.id = form.id
        this.$theia.http.get("/sso/user/role",postForm).then(res=>{
          that.form = Object.assign(that.form, res)
        //处理枚举重新绑定
          this.loadEnums_aaate()
          that.conf.loading = false
        }).catch(res=>{
          let code = ((res||{}).response||{}).status||0
          let msg = `用户权限查询失败(${code})`
          that.$notify.error({title: '失败',message:msg ,duration:5000})
        })
    },
    save(){
        this.$refs.form.validate((v=>{
            if(v) this.onSave()
        }))
    },
    onSave(){
      let that = this
        let postForm = Object.assign({},this.form)
        this.$theia.http.put("/sso/user/role",postForm).then(res=>{
            that.$notify.success({title: '成功',message: '用户权限保存成功',duration:5000})
            that.hide()
            that.$emit("onsaved")
        }).catch(res=>{
            let code = ((res||{}).response||{}).status||0
            let msg = `用户权限修改失败(${code})`
            that.$notify.error({title: '失败',message: msg,duration:5000})
        })
    },
    hide() {
      this.conf.visible = false;
      this.$refs.form.resetFields();
    },
     onUploadSuccess(response){
    },
    loadEnums_aaate(){
        //系统
        this.sys_idList = this.$theia.enum.get("system_info","","" ,false,"")
        //角色
        this.role_idList = this.$theia.enum.get("role_info","","" ,false,"")
        //状态
        this.statusList = this.$theia.enum.get("status","","" ,false,"")
    },

  },
};
</script>

<style scoped>
.form_item_info{
  margin-left: 4px;
  color:#999;
}
.form_item_info:hover{
  cursor: pointer;
  font-weight: 500;
  color:#333;
}
</style>